
export namespace validate {
    //小数点后最多两位   常用于金钱验证
    export const checkDecimal = (value: any): boolean => {
        return /^[0-9]+(.[0-9]{1,2})?$/.test(value)
    }
    //验证1到100
    export const checkNumberLessHundred = (value: string): boolean => {
        return /^([1-9][0-9]{0,1}|100)$/.test(value);
    }
    //验证整数 [-∞,+∞]
    export function checkInt(value: any) {
        return /^(0|[1-9][0-9]*|-[1-9][0-9]*)$/.test(value)
    }
    //验证正整数
    export function checkPositiveInt(value: any) {
        return /^([1-9]\d*)$/.test(value)
    }
    export const checkMobile = (value: any): boolean => {
        let reg = /^1(3\d|4[5-8]|5[0-35-9]|6[6]|7[2-8]|8\d|9[0-35-9])\d{8}$/
        return reg.test(value);
    }
    export const isBefore = (start: string, end: string): boolean => {
        if (start.indexOf(':') == -1 || end.indexOf(':') == -1) {
            // throw new Error(start + ' or ' + end + '不是HH:mm格式')
            return false;
        }
        let startArr = start.split(':');
        let endArr = end.split(':');
        let startHour = parseInt(startArr[0]);
        let startMin = parseInt(startArr[1]);
        let endHour = parseInt(endArr[0]);
        let endMin = parseInt(endArr[1]);
        if (startHour == endHour) {
            return startMin < endMin;
        }
        return startHour < endHour;
    }
    //校验车牌号
    export function checkPlateNo(value:string) {
        let reg1 = /^[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$/;
        let reg2 = /^[A-Z]{1}(([0-9]{5}[DF])|([DF][A-HJ-NP-Z0-9][0-9]{4}))$/;
        return reg1.test(value) || reg2.test(value);
    }
}